package com.study.jvm.classfile;

/**
 * Description:
 * User: tan
 * DateTime: 2017/10/23 16:23
 */
public class MyClassFileTest {

    private final int fa = 10;
    private final int fb = 100;

    private final long fla = 10;
    private final long flb = 1000000;

    private static int sa = 20;

    private final long flc = new Long(2000000);


    private String str1 = "abc";
    private String str3 = "abc";
    private String str4 = new String("abc");
    private String str2 = "abcde";

    public int sum(int a, int b) {
        int c = a + b;
        int d = 10;
        int f = c + d + fa;
        return f;
    }

    public void test() {
        int sum = sum(2, 100);
        long t = sum + 20 + fb + fla + flb;
        System.out.println(t);
        test1();
    }

    public void test2() {
        long t = fla + flb + flc + sa;
        System.out.println(t);
    }

    public void boxing() {
        Integer a = 10;//装箱  自动装箱时编译器调用valueOf将原始类型值转换成对象
        int b = new Integer(20);//拆箱  自动拆箱时，编译器通过调用类似intValue(),doubleValue()这类的方法将对象转换成原始类型值。
    }

    public void testString() {
        String str = "abc";
        String str1 = new String("abc1");
        String str2 = "bcd";
        String str3 = str + str1 + str2;


        String ss1 = "abc";
        String ss2 = "abc";
        String ss3 = new String("abc");

        System.out.println(ss1 == ss2);
        System.out.println(ss1 == ss3);
    }

    public void testFinal() {
        final double d1 = 3.14159;
        final double d3 = 66666.666;
        double d4 = 65475477.6;
    }

    public void test3() {
        String str = str1 + str2;
        System.out.println(str);
        System.out.println(str1 == str3);
        System.out.println(str1 == str4);
    }

    private int test1() {
        int a = 1;
        int b = 30;
        int d = 5200;
        int c = a + b + d;
        return c;
    }

    public static void main(String[] args) {
        MyClassFileTest test = new MyClassFileTest();
        test.test();
        test.test3();
    }
}
